package com.example.anliku.controller;

import com.example.anliku.entity.Download;
import com.example.anliku.entity.Example;
import com.example.anliku.entity.Message;
import com.example.anliku.service.DownloadService;
import com.example.anliku.service.ExampleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Api(tags = "下载模块")
@RestController
@RequestMapping("/api/download")
public class DownloadController {
    @Resource
    private DownloadService downloadService;

    @ApiOperation(value = "添加下载")
    @PostMapping("/one")
    public Message insert(Download download) {
        return downloadService.insertSelective(download);
    }

    @ApiOperation(value = "删除下载")
    @DeleteMapping("/delete")
    public Message delete(Integer downloadId) {
        return downloadService.deleteByPrimaryKey(downloadId);
    }

    @ApiOperation(value = "修改下载")
    @PostMapping("/put")
    public Message update(Download download) {
        return downloadService.updateByPrimaryKeySelective(download);
    }

    @ApiOperation(value = "获取所有下载")
    @GetMapping("/all")
    public Message selectAll(){
        return downloadService.selectAll();
    }

    @ApiOperation(value = "根据下载id获取下载")
    @GetMapping("/one")
    public Message selectByPrimaryKey(Integer downloadId){
        return downloadService.selectByPrimaryKey(downloadId);
    }

    @ApiOperation(value = "图表接口")
    @GetMapping("/chart")
    public Message chart(){
        return downloadService.chart();
    }

    @ApiOperation(value = "根据userid获取下载记录")
    @GetMapping("/userId")
    public Message selectByDownloadUserId(String downloadUserId){
        return downloadService.selectByDownloadUserId(downloadUserId);
    }

    @ApiOperation(value = "根据案例id获取下载记录")
    @GetMapping("/caseId")
    public Message selectByDownloadCaseId(String downloadCaseId) {
        return downloadService.selectByDownloadCaseId(downloadCaseId);
    }
}
